
/*
	imperavi object
*/
cms.plugins.imperavi = {}; 
cms.plugins.imperavi.redactor = [];
// Switch on imperavi handler
cms.plugins.imperavi.switchOn_handler = function( textarea_id )
{
	var page_id = parseInt( $('#PIPlugin').attr('rel') );
	cms.plugins.imperavi.redactor[textarea_id] = $('#'+textarea_id).redactor({
	
		image_upload: CMS_URL + ADMIN_DIR_NAME + '/plugin/imperavi/upload?folder=page_images&page_id=' + page_id,
		imageGetJson: CMS_URL + ADMIN_DIR_NAME + '/plugin/imperavi/images_json/' + page_id,
			
		file_upload: CMS_URL + ADMIN_DIR_NAME + '/plugin/imperavi/file_upload/' + page_id,	
		file_download: PUBLIC_URL + 'page_images/' + page_id + '/',		
		file_delete: CMS_URL + ADMIN_DIR_NAME + '/plugin/imperavi/file_delete/' + page_id + '/'
	});
};

// Switch off imperavi handler
cms.plugins.imperavi.switchOff_handler = function( textarea_id )
{
	cms.plugins.imperavi.redactor[textarea_id].destroy();
};


/*
	When DOM init
*/
jQuery(function(){

	//cms.imperavi.settings['language'] = imperavi_LOCALE;

	/*
		Add imperavi filter to filters stack
	*/
	cms.filters.add( 'imperavi', cms.plugins.imperavi.switchOn_handler, cms.plugins.imperavi.switchOff_handler );
});
